package com.ndphu.comic.gui.utils;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;

public class Utils {
	
	public static ProgressDialog getProgressDialog(Context context, int icon, String title, String message, Boolean isStoppable, DialogInterface.OnClickListener listener) {
		ProgressDialog dialog = new ProgressDialog(context);
		dialog.setTitle(title);
		dialog.setMessage(message);
		dialog.setCancelable(false);
		if (isStoppable) {
			dialog.setButton(ProgressDialog.BUTTON_NEGATIVE, "Stop", listener);
		}
		if (icon > 0) {
			dialog.setIcon(icon);
		}
		return dialog;
	}
	
	public static ProgressDialog getProgressDialog(Context context, String title, String message) {
		return getProgressDialog(context, -1, title, message, false, null);
	}
	
	public static ProgressDialog getProgressDialog(Context context, String title, String message, Boolean isStoppable, DialogInterface.OnClickListener listener) {
		return getProgressDialog(context, -1, title, message, isStoppable, listener);
	}
	
	public static AlertDialog getAlertDialog(Context context, int icon, String title, String message) {
		Builder builder = new Builder(context);
		AlertDialog alertDialog = builder.setTitle(title).setIcon(icon).setMessage(message).create();
		if (icon > 0) {
			alertDialog.setIcon(icon);
		}
		return alertDialog;
	}
	
	public static AlertDialog getAlertDialog(Context context, String title, String message) {
		return getAlertDialog(context, -1, title, message);
	}
}
